package cn.heygod.nacostool.session;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author Simon
 */
@Component
public class SessionManager {

    public static final String SESSION_KEY = "deploy_session";
    public void login(HttpServletRequest request,String username){
        request.getSession().setAttribute(SESSION_KEY,username);
    }

    public boolean isLogin(HttpServletRequest request){
        return request.getSession().getAttribute(SESSION_KEY) != null;
    }

    public void logout(HttpServletRequest request){
        request.getSession().removeAttribute(SESSION_KEY);
    }
}
